home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / smaltalk / gnu_st.lha / gnu_st / smalltalk-1.1.1 / mstsysdep.c < prev    next >
C/C++ Source or Header  |  1991-09-12  |  3KB  |  123 lines

  1. /***********************************************************************
  2.  *
  3.  *    System specific implementation module.
  4.  *
  5.  *    This module contains implementations of various operating system
  6.  *    specific routines.  This module should encapsulate most of these OS
  7.  *    specific calls so that the rest of the code is portable.
  8.  *
  9.  ***********************************************************************/
  10.  
  11. /***********************************************************************
  12.  *
  13.  * Copyright (C) 1990, 1991 Free Software Foundation, Inc.
  14.  * Written by Steve Byrne.
  15.  *
  16.  * This file is part of GNU Smalltalk.
  17.  *
  18.  * GNU Smalltalk is free software; you can redistribute it and/or modify it
  19.  * under the terms of the GNU General Public License as published by the Free
  20.  * Software Foundation; either version 1, or (at your option) any later 
  21.  * version.
  22.  * 
  23.  * GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  24.  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
  25.  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
  26.  * more details.
  27.  * 
  28.  * You should have received a copy of the GNU General Public License along with
  29.  * GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  30.  * Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  31.  *
  32.  ***********************************************************************/
  33.  
  34.  
  35. /*
  36.  *    Change Log
  37.  * ============================================================================
  38.  * Author      Date       Change 
  39.  * sbyrne    17 May 90      Added enableInterrupts and disableInterrupts.  System
  40.  *              V.3 code signal support from Doug McCallum (thanks,
  41.  *              Doug!).
  42.  *
  43.  * sbyrne    16 May 90      Created.
  44.  *
  45.  */
  46.  
  47. #include "mst.h"
  48. #include "mstsysdep.h"
  49. #include <signal.h>
  50.  
  51. #ifdef SYSV_3_SIGNALS
  52. static unsigned long __cursigmask; /* keep track of signal mask status */
  53. #endif
  54.  
  55. /*
  56.  *    IntState disableInterrupts()
  57.  *
  58.  * Description
  59.  *
  60.  *    Saves and returns the current state of the software interrupt system.
  61.  *    Disables all interrupts.
  62.  *
  63.  * Outputs
  64.  *
  65.  *    The old state of the interrupt system (presumably for saving for a
  66.  *    later call to enableInterrupts).
  67.  */
  68. IntState disableInterrupts()
  69. {
  70. #ifdef BSD_SIGNALS
  71.   return (sigsetmask(-1));
  72. #endif
  73. #ifdef SYSV_3_SIGNALS
  74.   unsigned long oldmask = __cursigmask;
  75.   register int i;
  76.  
  77.   __cursigmask = -1;
  78.   for (i=1; i <= 32; i++) {
  79.     sighold(i);        /* want it blocked - ok if it already is */
  80.   }
  81.   return oldmask;
  82. #endif
  83. }
  84.  
  85.  
  86. /*
  87.  *    void enableInterrupts(mask)
  88.  *
  89.  * Description
  90.  *
  91.  *    Restores the state of the interrupt system to that which it had when
  92.  *    "mask" was created. 
  93.  *
  94.  * Inputs
  95.  *
  96.  *    mask  : An interrupt state...should have been returned at some point
  97.  *        from a call to disableInterrupts.
  98.  *
  99.  */
  100. void enableInterrupts(mask)
  101. IntState mask;
  102. {
  103. #ifdef BSD_SIGNALS
  104.   sigsetmask(mask);
  105. #endif
  106. #ifdef SYSV_3_SIGNALS
  107.   unsigned long oldmask = __cursigmask;
  108.   register int i;
  109.  
  110.   __cursigmask = mask;
  111.   for (i=1; mask != 0; i++, mask >>= 1) { 
  112.     if (oldmask & (0x1 << (i-1))) {
  113.       sigrelse(i);    /* want it unblocked and it is blocked */
  114.     }
  115.   }
  116. #endif
  117. }
  118.  
  119.  
  120.  
  121.  
  122.  
  123.